import logging
from google.appengine.ext import webapp
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import urlfetch

class ReceiveEmail(InboundMailHandler):
	def receive(self,message):
		txtmsg = ""
		countp=0
                logging.info("Received email from %s" % message.sender)
                plaintext = message.bodies(content_type='text/plain')
                for text in plaintext:
                        txtmsg = ""
                        txtmsg = text[1].decode()
			countp = countp+1
			if countp == 1:
				urlfetch.fetch('http://imway.info/task/txt.php?til=hello2010')
                        logging.info("Body is %s" % txtmsg)								
                        
application = webapp.WSGIApplication([
  ReceiveEmail.mapping()
], debug=True)
def main():
  run_wsgi_app(application)
if __name__ == "__main__":
  main()